package es.usc.citius.openet.mg.tab.uiadapters;

import android.content.Context;
import android.os.Bundle;
import android.support.v4.app.Fragment;
import android.support.v4.app.FragmentManager;
import android.support.v4.app.FragmentPagerAdapter;
import es.usc.citius.openet.mg.tab.R;
import es.usc.citius.openet.mg.tab.fragments.DummySectionFragment;
import es.usc.citius.openet.mg.tab.fragments.FakeEventsFragment;
import es.usc.citius.openet.mg.tab.t5.Fragment5_1;
import es.usc.citius.openet.mg.tab.t5.Fragment5_2;
import es.usc.citius.openet.mg.tab.t5.Fragment5_3;
import es.usc.citius.openet.mg.tab.t5.Fragment5_Base;

/**
 * A {@link FragmentPagerAdapter} that returns a fragment corresponding to one
 * of the primary sections of the app.
 */
public class SectionsPagerAdapter extends FragmentPagerAdapter {

	private Context context;
	private Fragment5_Base fragmentBase;

	public SectionsPagerAdapter(Context context, FragmentManager fm) {
		super(fm);
		this.context = context;
		fragmentBase = new Fragment5_Base();
	}

	@Override
	public Fragment getItem(int i) {
		if (i == 0) {
			Fragment fragment = new FakeEventsFragment();
			return fragment;
		} else if (i == 1) {
			return fragmentBase;
		} else {
			Fragment fragment = new DummySectionFragment();
			Bundle args = new Bundle();
			args.putInt(DummySectionFragment.ARG_SECTION_NUMBER, i + 1);
			fragment.setArguments(args);
			return fragment;
		}
	}

	@Override
	public int getCount() {
		return 2;
	}

	@Override
	public CharSequence getPageTitle(int position) {
		switch (position) {
		case 0:
			return context.getString(R.string.title_section_fakeevents);
		case 1:
			return String.format(
					context.getString(R.string.title_section_fragment), 1);
		case 2:
			return String.format(
					context.getString(R.string.title_section_fragment), 2);
		}
		return null;
	}
}
